package 构造特定数组的逆序拼接.src.main;

import java.util.Arrays;
import java.util.stream.IntStream;

public class Main {
    public static int[] solution(int n) {
        // write code here
        int[] resultAarry = {};

        for (int temp = 1; temp <= n; temp++) {
            int[] arr1 = { temp };
            resultAarry = concatArrays(resultAarry, arr1);

        }

        return resultAarry;
    }

//    public static int[] concatArrays(int[] arr1, int[] arr2) {
//        return IntStream.concat(Arrays.stream(arr1), Arrays.stream(arr2)).toArray();
//    }

    public static int[] concatArrays(int[] arr1, int[] arr2) {
        int[] result = Arrays.copyOf(arr1, arr1.length + arr2.length);
        System.arraycopy(arr2, 0, result, arr1.length, arr2.length);
        return result;
    }
    public static void main(String[] args) {
        System.out.println(solution(3));
        System.out.println(concatArrays(new int[] { 1, 2 }, new int[] { 3, 4 }));

    }
}